package argo.hot100;

public class MaxArea {

    public int maxArea(int[] height) {

        int max = 0;
        int left = 0, right = height.length - 1;
        while (left < right) {
            int cur = Math.min(height[left], height[right]) * (right - left);
            max = Math.max(cur, max);
            if (height[left] <= height[right]) {
                left++;
            } else {
                right--;
            }
        }

        return max;
    }


    public static void main(String[] args) {
        System.out.println(new MaxArea().maxArea(new int[]{1, 8, 6, 2, 5, 4, 8, 3, 7}));
    }
}
